<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Drawer extends Model
{
    protected $dates = [
        'created_at',
        'updated_at',
    ];

    protected function goods()
    {
        return $this->hasMany(DrawerGood::class, 'drawer_id', 'id');
    }

    /**
     * 用户模型
     * @date 2017/7/23
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    protected function user()
    {
        return $this->belongsTo(User::class, 'user_id', 'id');
    }

    public function setNameAttribute($value)
    {
        $this->attributes['name'] = $value . '====';
    }

    public function getNameAttribute($value)
    {
        return ucfirst($value);
    }
}
